#ifndef XMLSRVHANDLER_H_
#define XMLSRVHANDLER_H_

#include "scHeader.h"
#include <QXmlDefaultHandler>
#include "DataTable.h"

namespace sybilpm
{

class XmlSrvHandler : public QXmlDefaultHandler
{
	enum ScanType
	{
		SCT_UNDEF	=0,
		SCT_DOC,
		SCT_DOMAIN,
		SCT_ENTITYLIST,
		SCT_ENTITYGROUP,
		SCT_ENTITY,
		SCT_SCOPE,
		SCT_SCOPEKEY
	};
	typedef std::vector<ScanType> ScanPath;

public:
	XmlSrvHandler(DataTables & dataTables, bool isBootTrans);
	virtual ~XmlSrvHandler();

	bool startDocument();
	bool endDocument();
	bool startElement(const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts);
	bool endElement(const QString & namespaceURI, const QString & localName, const QString & qName );

	bool warning(const QXmlParseException & exception);
	bool error(const QXmlParseException & exception);
	bool fatalError(const QXmlParseException & exception);

private:
	typedef std::vector<QString> MiniObject;
	typedef std::vector<MiniObject> MiniObjects;
	typedef std::map<PkType, MiniObjects> MiniTables;
	DataModel * dm;
	DataTables & dts;
	MiniTables mts;
	bool bootTrans;
	TimeType responseTime;
	DataDomain activeDomain;
	PkType activeTbl;
	DTsPkIdx::iterator tableIt;
	Request * activeRequest;
	ScanPath scpath;
};

} // namespace sybilpm

#endif /* XMLSRVHANDLER_H_ */
